// import city from '@/assets/json/area.json'
import {
  GET_BANNER_LIST,
  SET_BANNER_LIST,

  GET_TAB_LIST,
  SET_TAB_LIST,

  GET_leftTab_LIST,
  SET_leftTab_LIST,


  SET_addshopcar_LIST,
 
  GET_serch_LIST,
  SET_serch_LIST,





  } from '../type';
 
  import { banner,Tab,SortLeft } from '@/api/home';
  
  export interface IState {
    banner: Array<any>;
    tab:any;
    leftTab:any;
    shopcarlist:any;
    serch:any,
    city:any
  }
  export interface IAction {
    type: string;
    payload?: any;
  }
  export default {
    strict: true,
    namespace: 'home',
    state: {
        // city,
        banner: [],
        tab:[],
        leftTab:[],
        shopcarlist:[],

    },
    mutations: {
      [SET_BANNER_LIST](state: IState, { payload }: IAction) {
        state.banner = payload;
      },
      [SET_TAB_LIST](state: IState, { payload }: IAction) {
        state.tab = payload;
      },
      [SET_leftTab_LIST](state: IState, { payload }: IAction) {
        state.leftTab = payload;
      },
      [SET_addshopcar_LIST](state: IState, { payload }: IAction) {
        state.shopcarlist.push(payload);
      },

    },
    actions: {
      [ GET_BANNER_LIST]: async ({ commit }: any) => {
        const result = await banner();
        commit({ type: SET_BANNER_LIST, payload: result.data.data });  
      },
      [ GET_TAB_LIST]: async ({ commit }: any) => {
        const result = await Tab();
        commit({ type: SET_TAB_LIST, payload: result.data.data });  
      },
      [ GET_leftTab_LIST]: async ({ commit }: any) => {
        const result = await SortLeft();
        commit({ type: SET_leftTab_LIST, payload: result.data.data});  
        console.log(result);
      },
     
    },
  };